<%@include file="../../../base/include.jsp"%>
<%@include file="../../modal/preview.jsp"%>

<div class="page-header">
	<c:if test="${fromId == null}">
		<h3>Creating new user</h3>
	</c:if>
	<c:if test="${fromId != null}">
		<h3>Creating new user (from user ${fromId})</h3>
	</c:if>
</div>

<div>
	<form:form class="form-stacked" commandName="userCommand">
		<div class="clearfix">
			<label>Email (will be used as user login):</label>
			<form:input class="user-form-input" path="mail" maxlength="50"/>
			<form:errors path="mail" />
		</div>
		<div class="clearfix">
			<label>Password:</label>
			<form:input class="user-form-input" path="password" />			
			<form:errors path="password" />
		</div>
		<div class="clearfix">
			<label>Full Name:</label>
			<form:input class="user-form-input" path="name" maxlength="255"/>
			<form:errors path="name" />
		</div>		
		<form:hidden path="fromUserId" value="${fromId}"/>
	</form:form>
</div>

<script type="text/javascript">
	var mail = new LiveValidation('mail', {
		validMessage : ' ',
		onlyOnBlur : true
	});
	mail.add(Validate.Presence, {
		failureMessage : "Email cannot be empty."
	});
	mail.add(Validate.Email, {
		failureMessage : 'Email address is incorrect.'
	});

	var password = new LiveValidation('password', {
		validMessage : ' ',
		onlyOnBlur : true
	});
	password.add(Validate.Presence, {
		failureMessage : "Password can't be empty."
	});
	$('#menuAllUsers').addClass('active');
	setActiveMainMenuElem('administration');
	safetyLeave();
</script>

